GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

kendo.jQuery.ajaxSetup.beforeSend   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
/**
2
 * We'll load the axios HTTP library which allows us to easily issue requests
3
 * to our Laravel back-end. This library automatically handles sending the
4
 * CSRF token as a header based on the value of the "XSRF" token cookie.
5
 */
6
7
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
8
9
/**
10
 * Sett global authorization headers for js libraries
11
 */
12
window.axios.defaults.headers.common['Authorization'] = "Bearer " + Laravel.apiToken;
0 ignored issues
show
Bug introduced by
The variable Laravel seems to be never declared. If this is a global, consider adding a /** global: Laravel */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
13
$.ajaxSetup({
14
    beforeSend: function (xhr) {
15
        xhr.setRequestHeader("Authorization", "Bearer " + Laravel.apiToken);
0 ignored issues
show
Bug introduced by
The variable Laravel seems to be never declared. If this is a global, consider adding a /** global: Laravel */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
16
    }
17
});
18
kendo.jQuery.ajaxSetup({
0 ignored issues
show
Bug introduced by
The variable kendo seems to be never declared. If this is a global, consider adding a /** global: kendo */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
19
    beforeSend: function (xhr) {
20
        xhr.setRequestHeader("Authorization", "Bearer " + Laravel.apiToken);
0 ignored issues
show
Bug introduced by
The variable Laravel seems to be never declared. If this is a global, consider adding a /** global: Laravel */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
21
    }
22
});
23
24
/**
25
 * Next we will register the CSRF Token as a common header with Axios so that
26
 * all outgoing HTTP requests automatically have it attached. This is just
27
 * a simple convenience so we don't have to attach every token manually.
28
 */
29
30
let token = document.head.querySelector('meta[name="csrf-token"]');
31
32
if (token) {
33
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
34
} else {
35
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
36
}
37
38
/**
39
 * Echo exposes an expressive API for subscribing to channels and listening
40
 * for events that are broadcast by Laravel. Echo and event broadcasting
41
 * allows your team to easily build robust real-time web applications.
42
 */
43
44
// window.Echo = new Echo({
45
//     broadcaster: 'pusher',
46
//     key: 'your-pusher-key'
47
// });
48
49
// Material Buttons
50
$(() => {
51
    window['mmex'] = window['mmex'] || {};
52
    window['mmex']['momentLocal'] = (date) => {
53
        if (!date || _.isEmpty(date)) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
54
            return moment();
55
        }
56
57
        let m = moment(date);
58
        if (m.isValid()) {
59
            return m;
60
        }
61
        m = moment(date, "DD.MM.YYYY");
62
        if (m.isValid()) {
63
            return m;
64
        }
65
66
        throw new Error("No supported date format found for ", date);
67
    };
68
69
    $.material.init();
70
71
    autosize($('textarea'));
72
73
    $("[autofocus]").focus();
74
75
    $(".common-dateinput").each((index, elm) => {
76
        let val = $(elm).val();
77
        let date = mmex.momentLocal(val).toDate();
0 ignored issues
show
Bug introduced by
The variable mmex seems to be never declared. If this is a global, consider adding a /** global: mmex */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
78
        console.log("set date ", date, " out of ", val);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
79
        new kendo.ui.DateInput($(elm), {
0 ignored issues
show
Bug introduced by
The variable kendo seems to be never declared. If this is a global, consider adding a /** global: kendo */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Unused Code Best Practice introduced by
The object created with new kendo.ui.DateInput($...false),ListBuffer()))}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
80
            value: val ? date : new Date()
81
        });
82
    });
83
84
    $(".common-datepicker").each((index, elm) => {
85
        let val = $(elm).val();
86
        let date = mmex.momentLocal(val).toDate();
0 ignored issues
show
Bug introduced by
The variable mmex seems to be never declared. If this is a global, consider adding a /** global: mmex */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
87
        console.log("set date ", date, " out of ", val);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
88
        new kendo.ui.DatePicker($(elm), {
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new kendo.ui.DatePicker(...false),ListBuffer()))}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
Bug introduced by
The variable kendo seems to be never declared. If this is a global, consider adding a /** global: kendo */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
89
            value: val ? date : new Date()
90
        });
91
    });
92
93
    $(".common-dropdown-list").each((index, elm) => {
94
        new kendo.ui.DropDownList($(elm), {
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new kendo.ui.DropDownLis...teralNode(startswith)}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
Bug introduced by
The variable kendo seems to be never declared. If this is a global, consider adding a /** global: kendo */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
95
            filter: "startswith",
96
        });
97
    });
98
99
    $('textarea, input').keyup(function (e) {
100
        if (e.which == 17) isCtrl = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
The variable isCtrl seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.isCtrl.
Loading history...
101
    }).keydown(function (e) {
102
        if (e.which == 17) isCtrl = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
The variable isCtrl seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.isCtrl.
Loading history...
103
        if (e.which == 13 && isCtrl === true) {
0 ignored issues
show
Bug introduced by
The variable isCtrl does not seem to be initialized in case e.which == 17 on line 102 is false. Are you sure this can never be the case?
Loading history...
Complexity Best Practice introduced by
There is no return statement if e.which == 13 && isCtrl === true is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
104
            $(this).closest('form').submit();
105
            return false;
106
        }
107
    });
108
});